<template>
  <div class="bigAdd">
    <el-container>
      <el-main>
        <span>
          <div style="font-family: SimHei; font-size: 25px">
            <el-icon><Document /></el-icon>新建工单
            <el-icon style="margin-left: 61%"><Coin /></el-icon>悬赏金额
          </div>
          <el-input
            type="text"
            name="issuename"
            class="issuename"
            v-model="inputName"
            placeholder="请输入工单名"
          />
          <el-input
            size="large"
            type="text"
            style="width: 20%"
            v-model="money"
            placeholder="默认为0"
          ></el-input>
        </span>
        <div
          style="
            font-family: SimHei;
            font-size: 25px;
            margin-bottom: 10px;
            margin-top: 10px;
          "
        >
          <el-icon><Reading /></el-icon>工单内容
        </div>
        <v-md-editor
          v-model="text"
          height="400px"
          left-toolbar=""
          placeholder="请输入工单内容"
          mode="edit"
        ></v-md-editor>
        <div class="twobutton">
          <el-button type="primary" @click="submit" class="button1"
            >提交</el-button
          >
          <el-button @click="cancel" class="button2">取消</el-button>
        </div>
      </el-main>
      <el-dialog v-model="dialogVisible" title="Tips" width="30%">
        <span style="text-align: center; font-size: 20px"
          ><h3>成功新建工单</h3></span
        >
        <div style="text-align: center; margin-top: 50px">
          <el-button
            @click="closeDialog"
            size="large"
            style="color: coral; width: 200px"
            >ok</el-button
          >
        </div>
      </el-dialog>
      <el-aside>
        <!-- <div style="margin-top: 30px; font-family: SimHei; font-size: 25px">
          <el-icon><Coin /></el-icon>悬赏金额
          <div>
            <el-input
              size="large"
              style="width: 130px"
              v-model="money"
            ></el-input>
          </div>
        </div> -->
      </el-aside>
    </el-container>
  </div>
</template>

<script>
import request from "@/utils/request";
import { ElMessage } from "element-plus";
export default {
  name: "AssIssue",
  data() {
    return {
      dialogVisible: false,
      inputName: "",
      money: "",
      text: "",
    };
  },
  methods: {
    closeDialog() {
      this.$router.back();
    },
    submit() {
      if (this.inputName == "" || this.text == "") {
        ElMessage("请输入有效的内容");
      } else {
        request
          .post(
            `/issue/addIssue?ownername=${
              this.$route.params.username
            }&housename=${this.$route.params.housename}&issueName=${
              this.inputName
            }&issueContent=${this.text}&creatorName=${
              window.sessionStorage.getItem("username") + "&money=" + this.money
            }`
          )
          .then((res) => {
            if (res.code == 200) {
              this.dialogVisible = true;
            } else {
              ElMessage({
                message: res.message,
                type: "error",
              });
            }
          });
      }
    },
    cancel() {
      this.$router.back();
    },
  },
};
</script>

<style scoped>
.bigAdd {
  margin-left: 300px;
  margin-right: 400px;
}
.issuename {
  height: 40px;
  font-size: 20px;
  margin-top: 10px;
  width: 70%;
  margin-right: 10%;
}
.chosepriority {
  margin-top: 40px;
  margin-bottom: 30px;
}
.twobutton {
  margin-top: 20px;
  margin-left: 50px;
  margin-right: 50px;
  padding-right: 100px;
  padding-left: 100px;
  display: flex;
  justify-content: space-between;
}
.button1 {
  width: 200px;
}
.button2 {
  width: 200px;
}
</style>
